package cn.yusei.teamTribe.dao.user;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import cn.yusei.teamTribe.dao.user.po.UserInfoPO;

@Component
public interface UserInfoDAO {

	final String USER_INFO_TABLE = "e_user_info";
	final String SELECT_FIELDS = "id, nickname, portrait, create_time, is_public, school_id, no, name, gender, birthday, academy, major, grade, cla";
	
	@Select({"select ", SELECT_FIELDS, " from ", USER_INFO_TABLE, " where id = #{id}"})
	UserInfoPO select(@Param("id") int id);
	
	@Update({"update ", USER_INFO_TABLE, " set nickname = #{nickname}, portrait = #{portrait}, is_public = #{isPublic} where id = #{id}"})
	void update(UserInfoPO user);
	
	@Update({"update ", USER_INFO_TABLE,
		" set no = #{no}, name = #{name}, gender = #{gender}, birthday = #{birthday},",
		" school_id = #{schoolId}, academy = #{academy}, major = #{major}, grade = #{grade}, cla = #{cla}",
		" where id = #{id}"})
	void updateAuth(UserInfoPO user);
	
}
